﻿@{
    Layout = null;
}

<!DOCTYPE html>
<html>
<head>
    <link rel="shortcut icon" href="favicon.ico">
    <link rel="icon" type="image/gif" href="~/img/animated_favicon1.gif">
    <link href="~/UILibs/easyui/themes/default/easyui.css" rel="stylesheet" />
    <link href="~/UILibs/easyui/themes/icon.css" rel="stylesheet" />
    <link href="~/Css/css.css" rel="stylesheet" />

    <script src="~/Scripts/jquery-1.7.1.min.js"></script>
    <script src="~/Scripts/jquery.jqprint-0.3.js"></script>
    <script src="~/UILibs/easyui/jquery.easyui.min.js"></script>

    <script src="~/UILibs/easyui/locale/easyui-lang-zh_CN.js"></script>
    <script src="~/Scripts/jquery.unobtrusive-ajax.min.js"></script>
    <script src="~/Scripts/jquery.validate.min.js"></script>
    <script src="~/Scripts/jquery.validate.unobtrusive.min.js"></script>
    <script src="~/Scripts/datagrid-detailview.js"></script>
    <title></title>
    <script src="https://cdn.bootcss.com/blueimp-md5/2.10.0/js/md5.js"></script>
    <script type="text/javascript">

        $(function () {

            $('#txtDate2').datebox({
                onSelect: function () { searchData() }
            });
            $("#data").datagrid({
                fit: true,
                title: '理货员下架记录表',
                striped: true,
                rownumbers: true,
                columns:    // logId  logTime  logType  waresCode     status   RealName   userid  storeName    waresName num
                    [[
                            { field: 'logId', title: '操作编号', width: 80, halign: 'center', align: 'center' },
                            { field: 'userid', title: '操作人员编号', width: 0, halign: 'center', align: 'center', hidden: true },
                            { field: 'RealName', title: '操作人姓名', width: 100, halign: 'center', align: 'center' },
                            { field: 'logType', title: '操作类型', width: 80, halign: 'center', align: 'center', },
                            { field: 'waresCode', title: '商品编号', width: 120, halign: 'center', align: 'center' },
                            { field: 'waresName', title: '商品名称', width: 220, halign: 'center', align: 'center', },
                            { field: 'num', title: '操作数量', width: 80, halign: 'center', align: 'center', },
                            { field: 'storeName', title: '店铺名称', width: 150, halign: 'center', align: 'center', },
                            { field: 'logTime', title: '操作时间', width: 180, halign: 'center', align: 'center', },
                            { field: 'logReason', title: '下架原因', width: 220 , halign: 'center', align: 'center' },
                            {
                                field: 'status', title: '是否驳回该操作', width: 150, align: "center", formatter: formatOper
                            },
                            {
                                field: 'downWaresState', title: '下架商品状态', width: 200, align: "center", 
                            }

                    ]],
                singleSelect: true,
                loadMsg: '正在加载数据,请耐心等待.......',    ///  
                url: pageConfig.getAction,
                queryParams: {
                    date1: $('#txtDate1').val(),
                    date2: $('#txtDate2').val(),
                },
                pagination: true,
                pageSize: 25,
                pageList: [25, 30, 35],
                sortName: 'logId',
                sortOrder: 'desc',
                toolbar: '#tool',
            });
            $("#formdialog").dialog({
                width: 400,
                height: 250,
                closed: true,
                modal: true,
                buttons: '#btns',
            });

        });

        var pageConfig = {
            getAction: '@Url.Action("GetNotice")',
            modifyAction: '@Url.Action("ModifyReply")',

        };
        // 回复按扭 1.点击驳回 0. 已经驳回  foever
        function formatOper(val, row, index) {
            if (val == 1) {
                return "<a href='#' style='color:red' onclick=alertFormDialog(" + row.userid + "," + row.logId + ",'" + row.RealName + "','" + row.waresName + "','" + row.storeName + "','" + row.waresCode + "','" + row.logType + "'," + row.num + ")>点击驳回</a>";
            }
            if (val == 0) {
                return "<a href='#' style='color:green'  )>已驳回，等待处理</a>";
            }
            if (val == 2) {
                return "<a href='#' style='color:gray'  )>理货员已处理</a>";
            }
        }

        // 群发 发送按钮 ," + row.logType + "," + row.num + "  , logType, num
        function alertFormDialog(userid, logId, RealName, waresName, storeName, waresCode, logType, num) {
            //alert(userid);
            //alert(logId);
            var rows = $("#data").datagrid("getSelections");
            var data;
            data = {
                RealName: RealName,
                userid: userid,
                logId: logId,
                waresName: waresName,
                waresCode: waresCode,
                num: num,
                storeName: storeName,

                logType: logType,
            };
            $.ajax({
                url: "/OperateLog/Reject",
                datatype: "JOSN",
                data: data,
                type: "post",
                beforeSend: function () {
                    $.messager.progress({ title: "执行中", text: "" });
                },
                success: function (data) {

                    $.messager.alert("成功", data.msg, "info");
                },
                error: function (data) {
                    $.messager.alert("警告", "系统故障", "error", "")
                },
                complete: function () {

                    complete();
                }
            });
        }


        //查询
        function searchData() {
            var start = $("#txtDate1").datebox('getValue');//
            var end = $("#txtDate2").datebox('getValue');
            if ((start == null || end == null) && (end == "" || end == ""())) {
                alert("开始日期和结束时间不能为空");
                txtDate1.focus();
                return false;
            }
            else if (txtDate1.value > txtDate2.value) {

                alert("开始日期不能大于截至日期！");
                $("#txtDate1").textbox('setValue');//清空文本框的值
                $("#txtDate1").textbox('clear');
                $("#txtDate2").textbox('setValue');
                $("#txtDate2").textbox('clear');

                txtDate1.focus();
                txtDate2.focus();
                return false;
            }
            else {
                $("#data").datagrid('load', {
                    date1: $('#txtDate1').val(),
                    date2: $('#txtDate2').val(),
                });
            }
        }

        //取消按钮
        function closeDptDialog() {
            $("#formdialog").dialog("close")
        }

        function complete() {
            $("#data").datagrid("load");
            $.messager.progress("close");
        }

    </script>
</head>
<body class="easyui-layout" style="width: 100%; height: 100%">
    <div data-options="region:'center'" id="dataPrint">

        <table id="data" style="height: 50px"></table>

    </div>

    <div id="tool" style="padding: 30px;">
        <form id="formid" method='post' action='/OrderStatistic/Excel'>
        </form>
        <div>
            &nbsp&nbsp&nbsp &nbsp&nbsp&nbsp 
               日期：<input id="txtDate1" type="text" class="easyui-datebox" onchange="searchData()" />
            -- 
                <input id="txtDate2" type="text" class="easyui-datebox" onchange="searchData()" />
            &nbsp&nbsp&nbsp &nbsp&nbsp&nbsp &nbsp&nbsp&nbsp &nbsp&nbsp&nbsp 
            <a class="easyui-linkbutton" iconcls="icon-search" onclick="searchData();">查询</a>
            &nbsp&nbsp&nbsp &nbsp&nbsp&nbsp &nbsp&nbsp&nbsp &nbsp&nbsp&nbsp 

        </div>

    </div>


    <style>
        #dataPrint.datagrid-btable tr {
            height: 50px;
        }
    </style>
</body>
</html>
